package chpt11;

import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.Date;

public class HeaderAccess {
	public static void main(String[] args) {
		try {
			URL url = new URL("http://www.example.com/");
			URLConnection con = url.openConnection();
			print("Content-type:" + con.getContentType());
			print("Content-encoding:" + con.getContentEncoding());
			print("Content-length:" + con.getContentLength());
			print("Date:" + new Date(con.getDate()));
			print("Last modified:" + new Date(con.getLastModified()));
			print("Expiration date:" + new Date(con.getExpiration()));
		} catch (MalformedURLException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	private static void print(String s) {
		System.out.println(s);
	}
}
